<template>
  <div>
    <el-upload
      class="upload-demo"
      ref="upload"
      :action="action"
      :headers="myHeaders"
      :on-success="handleSuccess"
      :show-file-list="false"
    >
      <el-button slot="trigger" size="small" type="primary">上传文件</el-button>
    </el-upload>
  </div>
</template>
<script>
export default {
  data() {
    return {
      myHeaders: {token: sessionStorage.getItem('token')},
      action: this.$BaseUrl+"/file/uploadFile",
    };
  },
  methods: {
    /*上传完毕回调*/
    handleSuccess(res){
      if(res.code===200){
        this.$message.success("上传成功")
        this.$emit('updateList',null)
      }else {
        this.$message.error(res.msg);
      }
    }
  }
}
</script>
